package com.blue.bluecode;

import android.app.Activity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.blue.bluecode.adapter.RVAdapter;
import com.blue.bluecode.entity.Person;

import java.util.ArrayList;
import java.util.List;


public class RecyclerViewActivity extends Activity {

    private List<Person> persons;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recycler_view);
        getActionBar().setDisplayHomeAsUpEnabled(true);

        initializeData();
        RecyclerView rv = (RecyclerView) findViewById(R.id.rv);

        LinearLayoutManager llm = new LinearLayoutManager(RecyclerViewActivity.this);
        rv.setLayoutManager(llm);
        rv.setHasFixedSize(true);
        RVAdapter rvAdapter = new RVAdapter(RecyclerViewActivity.this,persons);
        rv.setAdapter(rvAdapter);
    }


    private void initializeData(){
        persons = new ArrayList<>();
        persons.add(new Person("张统玮","26岁",R.mipmap.test1));
        persons.add(new Person("张云辉","26岁",R.mipmap.test2));
        persons.add(new Person("杨威","25岁",R.mipmap.test3));
        persons.add(new Person("吴格非","25岁",R.mipmap.test4));
        persons.add(new Person("宋煌钟","24岁",R.mipmap.test5));
    }

}
